package cn.itcast.dao;

import cn.itast.domain.Member;
import cn.itast.domain.Orders;
import cn.itast.domain.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IOrdersDao {

    @Select("select * from orders")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "orderNum" , column = "orderNum"),
            @Result(property = " orderTime" , column = " orderTime"),
            @Result(property = "orderStatus" , column = "orderStatus"),
            @Result(property = "peopleCount" , column = "peopleCount"),
            @Result(property = "payType" , column = "payType"),
            @Result(property = "orderDesc" , column = "orderDesc"),
            @Result(property = "product",column = "productId",javaType = Product.class,one = @One(select = "cn.itcast.dao.IProductDao.findOneById"))
    })
    public List<Orders> findAll();

    @Select("select * from orders where id = #{ordersId}")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "orderNum" , column = "orderNum"),
            @Result(property = " orderTime" , column = " orderTime"),
            @Result(property = "orderStatus" , column = "orderStatus"),
            @Result(property = "peopleCount" , column = "peopleCount"),
            @Result(property = "payType" , column = "payType"),
            @Result(property = "orderDesc" , column = "orderDesc"),
            @Result(property = "product",column = "productId",javaType = Product.class,one = @One(select = "cn.itcast.dao.IProductDao.findOneById")),
            @Result(property = "member",column = "memberId" ,javaType = Member.class,one = @One(select = "cn.itcast.dao.IMemberDao.findById")),
            @Result(property = "travellers",column = "id",javaType = java.util.List.class,many = @Many(select = "cn.itcast.dao.ITravellerDao.findTravellersById"))
    })
    public Orders findById(String ordersId);

}
